package win.larryzeal.spring.theme.web.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.IOException;

/**
 * Created by 张少昆 on 2017/8/28 0028.
 */
@Controller
@RequestMapping( "/upload" )
public class UploadController {

	@RequestMapping( "/test" )
	@ResponseBody
	public String test(@RequestParam( "xxx" ) MultipartFile file){
		System.out.println("file.name: " + file.getName());
		System.out.println("file.contentType: " + file.getContentType());
		try{
			file.transferTo(new File("e:/xxx.txt"));
		} catch(IOException e){
			e.printStackTrace();
		}
		return "upload:ok";
	}
}
